                                                                                     
/*  Purpose:                                                                         
 *	  Erase all duplicate items in a vector<T>                            
 *  Time:                                                                            
 *     2003.7.15                                                                     
 *  Author:                                                                          
 *     jzhang(jzhang533@263.net)                                                     
 *  Parameters:                                                                      
 *     vec [IN][OUT] Remove the duplicate items in it                              
 */                                                                                  
                                                                                     
template <typename T>                                                           
void EraseDuplicate( vector<T> &vec)                                            
{                                                                               
	vector<T> Org;                                                          
	copy(vec.begin(),vec.end(),back_inserter(Org));                         
	vec.clear();                                                            
	                                                                        
	for( vector<T>::iterator ii = Org.begin();ii<Org.end(); ii++ )          
	{                                                                       
		vector<T>::iterator findresult= find(vec.begin(),vec.end(),*ii);
		                                                                
		if( findresult == vec.end() )// not found                       
		{                                                               
			vec.push_back(*ii);                                     
		}                                                               
	}	                                                                
}                                                                               
void Print(const string& str)                                                        
{                                                                                    
	cout<<str<<endl;                                                             
}                                                                                    
                                                                                     
int main(int argc, char* argv[])                                                     
{                                                                                    
	vector<string> Growing;                                                      
                                                                                     
	Growing.push_back("was");                                                    
	Growing.push_back("was");                                                    
	Growing.push_back("was");                                                    
	Growing.push_back("were");                                                   
	Growing.push_back("were");                                                   
	Growing.push_back("was");                                                    
	Growing.push_back("was");                                                    
                                                                                     
	EraseDuplicate(Growing);                                                     
	for_each(Growing.begin(),Growing.end(),Print);                               
	return 0;                                                                    
}                                                                                    